#!/usr/bin/env python
# coding:utf-8
# @author heitfei

'''
tcp time client tcp using socket
长链接形式
'''

import socket

HOST = 'localhost'
PORT = 23567
BUFFSIZE = 1024
ADDR = (HOST, PORT)

while True:
    tsCliSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
    tsCliSocket.connect(ADDR)
    data = raw_input('> ')
    if not data:
        break
    tsCliSocket.send('%s\r\n' % data)
    data = tsCliSocket.recv(BUFFSIZE)
    if not data:
        break
    print "recv =", data.strip()
    tsCliSocket.close()
